home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Space & Astronomy
/
Space and Astronomy (October 1993).iso
/
mac
/
VIEWERS
/
X11
/
XLOADIMG.TAR
/
imagetypes.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-20
|
2KB
|
101 lines
/* imagetypes.c:
*
* this contains things which reference the global ImageTypes array
*
* jim frost 09.27.89
*
* Copyright 1989, 1991 Jim Frost.
* See included file "copyright.h" for complete copyright information.
*/
#include "copyright.h"
#include "image.h"
#include "imagetypes.h"
#include <errno.h>
/* SUPPRESS 560 */
extern int errno;
/* load a named image
*/
Image *loadImage(name, verbose)
char *name;
unsigned int verbose;
{ char fullname[BUFSIZ];
Image *image;
int a;
if (findImage(name, fullname) < 0) {
if (errno == ENOENT)
printf("%s: image not found\n", name);
else
perror(fullname);
return(NULL);
}
for (a= 0; ImageTypes[a].loader; a++)
if (image= ImageTypes[a].loader(fullname, name, verbose)) {
zreset(NULL);
return(image);
}
printf("%s: unknown or unsupported image type\n", fullname);
zreset(NULL);
return(NULL);
}
/* identify what kind of image a named image is
*/
void identifyImage(name)
char *name;
{ char fullname[BUFSIZ];
int a;
if (findImage(name, fullname) < 0) {
if (errno == ENOENT)
printf("%s: image not found\n", name);
else
perror(fullname);
return;
}
for (a= 0; ImageTypes[a].identifier; a++) {
if (ImageTypes[a].identifier(fullname, name)) {
zreset(NULL);
return;
}
}
zreset(NULL);
printf("%s: unknown or unsupported image type\n", fullname);
}
/* tell user what image types we support
*/
void supportedImageTypes()
{ int a;
printf("Image types supported:\n");
for (a= 0; ImageTypes[a].name; a++)
printf(" %s\n", ImageTypes[a].name);
}
void goodImage(image, func)
Image *image;
char *func;
{
if (!image) {
printf("%s: nil image\n", func);
exit(0);
}
switch (image->type) {
case IBITMAP:
case IRGB:
case ITRUE:
break;
default:
printf("%s: bad destination image\n", func);
exit(0);
}
}